/**
 * @Date: Mar 3, 2010 4:26:27 PM
 */
package com.philip.journal.core.service;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import com.philip.core.BusinessServiceFacade;
import com.philip.journal.core.bean.User;
import com.philip.journal.home.bean.Branch;
import com.philip.journal.home.bean.Category;
import com.philip.journal.home.bean.Entry;
import com.philip.journal.home.service.EntryService;
import com.philip.journal.home.service.HomeService;
import com.philip.journal.home.service.ImportExportXmlService;
import com.philip.journal.login.service.LoginService;

/**
 * All methods here are Delegate methods to their corresponding service classes.
 *
 * @author cry30
 */
public class ServiceFacade extends BusinessServiceFacade implements HomeService, LoginService, EntryService,
        ImportExportXmlService { // NOPMD by r39

    /** RTFC. */
    private transient HomeService homeService;

    /** RTFC. */
    private transient LoginService loginService;

    /** RTFC. */
    private transient EntryService entryService;

    /** RTFC. */
    private transient ImportExportXmlService xmlService;

    // HOME SERVICE
    @Override
    public String getEntryTreePath(final Map<String, Object> session, final Entry entry) {
        return homeService.getEntryTreePath(session, entry);
    }

    @Override
    public List<Map<String, Object>> getPreferences(final Map<String, Object> session) {
        return homeService.getPreferences(session);
    }

    @Override
    public void moveBranch(final Map<String, Object> session, final long newParentId, final long branchId)
    {
        homeService.moveBranch(session, newParentId, branchId);
    }

    @Override
    public Map<String, Object> getNodeProperties(final Map<String, Object> session, final long nodeId,
            final boolean isEntry) {
        return homeService.getNodeProperties(session, nodeId, isEntry);
    }

    @Override
    public List<Branch> getChildren(final Map<String, Object> session, final long parentId) {
        return homeService.getChildren(session, parentId);
    }

    @Override
    public long addBranch(final Map<String, Object> session, final long parentId, final String branchName)
    {
        return homeService.addBranch(session, parentId, branchName);
    }

    @Override
    public void deleteBranch(final Map<String, Object> session, final long branchId)
    {
        homeService.deleteBranch(session, branchId);
    }

    @Override
    public void renameBranch(final Map<String, Object> session, final long branchId, final String newBranchName)
    {
        homeService.renameBranch(session, branchId, newBranchName);
    }

    // ENTRY SERVICE
    @Override
    public List<Entry> searchEntriesSimple(final Map<String, Object> session, final String searchParam)
    {
        return entryService.searchEntriesSimple(session, searchParam);
    }

    @Override
    public List<Entry> searchEntriesSimple(final Map<String, Object> session, final String searchParam,
            final String sortField, final String direction)
    {
        return entryService.searchEntriesSimple(session, searchParam, sortField, direction);
    }

    @Override
    public void importCodeXML(final Map<String, Object> session, final InputStream xmlData)
    {
        xmlService.importCodeXML(session, xmlData);
    }

    @Override
    public void exportToXML(final Map<String, Object> session, final OutputStream targetStream)
    {
        xmlService.exportToXML(session, targetStream);
    }

    @Override
    public void renameEntry(final Map<String, Object> session, final long entryId, final String newTitle)
    {
        entryService.renameEntry(session, entryId, newTitle);
    }

    @Override
    public void moveEntry(final Map<String, Object> session, final long newParentId, final long entryId)
    {
        entryService.moveEntry(session, newParentId, entryId);
    }

    @Override
    @Deprecated
    public List<Category> getCategories(final Map<String, Object> session) {
        return entryService.getCategories(session);
    }

    @Override
    public List<Entry> getEntries(final Map<String, Object> session, final long branchId) {
        return entryService.getEntries(session, branchId);
    }

    @Override
    public Entry getEntryDetail(final Map<String, Object> session, final long entryId) {
        return entryService.getEntryDetail(session, entryId);
    }

    @Override
    public long saveEntry(final Map<String, Object> session, final long branchId, final long entryId,
            final String title, final String description)
    {
        return entryService.saveEntry(session, branchId, entryId, title, description);
    }

    @Override
    public void deleteEntry(final Map<String, Object> session, final long entryId)
    {
        entryService.deleteEntry(session, entryId);
    }

    // LOGIN SERVICE
    @Override
    public User authenticateUser(final Map<String, Object> session, final String username, final String password)
    {
        return loginService.authenticateUser(session, username, password);
    }

    @Override
    public User getCurrentUser(final Map<String, Object> session) {
        return loginService.getCurrentUser(session);
    }

    @Override
    public void changePassword(final Map<String, Object> session, final String oldPassword, final String newPassword)
    {
        loginService.changePassword(session, oldPassword, newPassword);
    }

    // SERVICES
    public void setHomeService(final HomeService pHomeService) {
        this.homeService = pHomeService;
    }
    public void setLoginService(final LoginService pLoginService) {
        this.loginService = pLoginService;
    }

    public void setEntryService(final EntryService pEntryService) {
        this.entryService = pEntryService;
    }

    public void setImportExportXmlService(final ImportExportXmlService pXmlService) {
        this.xmlService = pXmlService;
    }

}
